const path = require('path');
const htmlWebpackPlugin = require('html-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
module.exports = {
  entry: './src/index.js',
  output: {
    filename: 'main.js',
    path: path.resolve(__dirname, 'dist')
  },
  // devServer:{
  //   open:true,
  //   contentBase:'src',
  //   port:8082,
  //   hot:true
  // },
  plugins:[
    new htmlWebpackPlugin({
      template:path.join(__dirname,'./src/index.html'),
      filename:'index.html'
    }),
    new VueLoaderPlugin()
  ],
  module:{    //这个模块用于配置所有第三方模块
    rules:[      //所有第三方模块的匹配规则
        {test:/\.css$/,use:['style-loader','css-loader']},
        {test:/\.scss$/,use:['style-loader','css-loader','sass-loader']},
        {test:/\.(ttf|eot|svg|woff|woff2)$/,use:'url-loader'},
        {test:/\.(jpg|png)$/,use:'url-loader?limit=41376&name=[hash:8]-[name].[ext]'},
        //图片大小小于限制时会自动转成 base64 码引用
        {test:/\.js$/,use:'babel-loader',exclude:/node_modules/},
        {
          test: /\.vue$/,
          loader: 'vue-loader'
        }   //vue加载模块
        
    ]  
  },
  resolve:{
    alias:{
      // 'vue$':'vue/dist/vue.js'
    }
  }
};